Class | Kar
In: | app/models/kar.rb
Parent: | Object

### Methods

new totaalprijs voeg_product_toe

### Attributes

items | [R] |

### Public Class methods

new()

[Source]

       # File app/models/kar.rb, line 4
    4:   def initialize
    5:     @items = []
    6:   end

### Public Instance methods

totaalprijs()

[Source]

        # File app/models/kar.rb, line 17
    17:   def totaalprijs
    18:     @items.sum { |item| item.prijs }
    19:   end

voeg_product_toe(product)

[Source]

        # File app/models/kar.rb, line 8
     8:   def voeg_product_toe(product)
     9:    huidig_item = @items.find {|item| item.product == product}
    10:    if huidig_item           # product zit reeds in de winkelkar
    11:      huidig_item.verhoog_aantal
    12:    else                       # dit product zit nog niet in de winkelkar
    13:      @items << KarItem.new(product)
    14:    end
    15:   end

[Validate]